home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mmpp010.zip / TELEP.CP_ / TELEP.bin
Text File  |  1995-03-30  |  10KB  |  250 lines

  1. // CopyRight Maurizio Maccani 1995
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <stdlib.h>
  5. #include <direct.h>
  6. #include "trainplb.h"
  7. #include "demo.h"
  8. #include "demo1.h"
  9. #include "csh.h"
  10.  
  11. long FAR PASCAL _export TestProc(HWND hwnd, UINT message, UINT wParam,
  12.                                                  LONG lParam);
  13.  
  14. // This line is needed to start the STP product
  15.  
  16.  
  17. HINSTANCE       hInst;
  18. HINSTANCE       telLib;
  19. HINSTANCE       training;
  20. typedef BOOL * (WINAPI * PLAYBACK) (LPSTR,BOOL,BOOL);
  21. PLAYBACK Pl;
  22.  
  23. BOOL FAR PASCAL __export TestDialogProc(HWND hDlg, UINT uMsg,
  24.                                               WPARAM wParam, LPARAM lParam);
  25.  
  26. int PASCAL      WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  27.                                         LPSTR lpszCmdParam, int nCmdShow)
  28. {
  29.     MSG             msg;
  30.     WNDCLASS        wndclass;
  31.     hInst = hInstance;
  32.     wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW | CS_BYTEALIGNCLIENT | CS_GLOBALCLASS | CS_DBLCLKS;
  33.     wndclass.cbClsExtra = 0;
  34.     wndclass.cbWndExtra = 4;
  35.     wndclass.hInstance = hInstance;
  36.     wndclass.hIcon = LoadIcon(hInstance, "icon");
  37.     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  38.     wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
  39.     wndclass.lpszMenuName = "menu";
  40.     wndclass.lpfnWndProc = TestProc;
  41.     wndclass.lpszClassName = "test2";
  42.     RegisterClass(&wndclass);
  43.     /**********************************************/
  44.     /* Remember to load the DLL                   */
  45.     /**********************************************/
  46.  
  47.     telLib = LoadLibrary("telephon.dll");
  48.     training = LoadLibrary("training\\stpredis.dll");
  49.     Pl = (PLAYBACK) GetProcAddress(training, "Playback");
  50.     int             ret = SetHelpFile(".\\HELP\\TELEPHON.HLP");
  51.     if (ret)
  52.         switch (ret) {
  53.         case HELP_FILE_DO_NOT_EXISTS:
  54.             MessageBox(NULL, "Not existing Help File", "Error", MB_ICONSTOP | MB_OK);
  55.             break;
  56.         }
  57.     SetDefaultHelp(1);
  58.     HWND            hwndHello = CreateWindow("test2",   // window class name
  59.                                              "Test Telephone Library",  // window caption
  60.                                              WS_OVERLAPPEDWINDOW,       // window style
  61.                                              100, 100, 350, 320,
  62.                                              NULL,      // parent window handle
  63.                                              NULL,      // window menu handle
  64.                                              (HINSTANCE) hInstance,     // program instance
  65.                                                                         // handle
  66.                                              NULL);     // creation parameters
  67.     SetWindowHelp(hwndHello, 1);
  68.     ShowWindow(hwndHello, SW_SHOW);
  69.     UpdateWindow(hwndHello);
  70.     while (GetMessage(&msg, NULL, 0, 0)) {
  71.         TranslateMessage(&msg);
  72.         DispatchMessage(&msg);
  73.     }
  74.     FreeLibrary(telLib);
  75.     FreeLibrary(training);
  76.     return msg.wParam;
  77. }
  78. long FAR PASCAL _export TestProc(HWND hwnd, UINT message, UINT wParam,
  79.                                                  LONG lParam)
  80. {
  81.     switch (message) {
  82.  case END_PLAYBACK_MESS:
  83.         PostQuitMessage(0);
  84.         return 0;
  85.     case WM_CREATE:
  86.         {
  87.             int             i = 54;
  88.  
  89.             HWND            telNumber = CreateWindow("Telephone", "3336788", WS_CHILD | WS_VISIBLE, 120, 20, 200, 95, hwnd, 1, hInst, &i);
  90.             SetWindowHelp(telNumber, 0x0052);
  91.             HWND            telNumber1 = CreateWindow("Telephone", "", WS_CHILD | WS_VISIBLE, 120, 50, 200, 125, hwnd, 1, hInst, NULL);
  92.             SetWindowHelp(telNumber1, 0x0053);
  93.             HWND            NumberS = CreateWindow("Static", "Filled", WS_CHILD | WS_VISIBLE, 10, 20, 100, 25, hwnd, 1, hInst, NULL);
  94.             HWND            ZeroNumberS = CreateWindow("Static", "Empty", WS_CHILD | WS_VISIBLE, 10, 50, 100, 25, hwnd, 1, hInst, NULL);
  95.             HWND            NumberS2 = CreateWindow("Static", "Other Font", WS_CHILD | WS_VISIBLE, 10, 80, 100, 25, hwnd, 1, hInst, NULL);
  96.             HWND            telNumber2 = CreateWindow("Telephone", "", WS_CHILD | WS_VISIBLE, 120, 80, 200, 125, hwnd, 1, hInst, NULL);
  97.             SetWindowHelp(telNumber1, 0x0054);
  98.             LOGFONT FAR    *plf = (LOGFONT FAR *) GlobalAllocPtr(GMEM_ZEROINIT, sizeof(LOGFONT));
  99.             HDC             hdc = GetWindowDC(hwnd);
  100.             int             Yinch = GetDeviceCaps(hdc, LOGPIXELSY);
  101.             ReleaseDC(hwnd, hdc);
  102.             plf->lfHeight = -((16 * Yinch) / 72);
  103.             plf->lfWeight = FW_NORMAL;
  104.             lstrcpy(plf->lfFaceName, "Times New Roman");
  105.             HFONT           nFont = CreateFontIndirect(plf);
  106.             SendMessage(telNumber2, WM_SETFONT, nFont, MAKELONG(TRUE, 0));
  107.             GlobalFreePtr(plf);
  108.             SetWindowLong(hwnd, 0, nFont);
  109.             SetMenuHelp(hwnd, EXIT, 0x0041);
  110.             SetMenuHelp(hwnd, DIALOG_STRING, 0x0042);
  111.             SetMenuHelp(hwnd, INTRODUCTION_TRAINING, 0x0043);
  112.             SetMenuHelp(hwnd, MODEM_TRAINING, 0x0044);
  113.             SetMenuHelp(hwnd, DATA_BASE_TRAINING, 0x0045);
  114.             SetMenuHelp(hwnd, PORTABLE_TRAINING, 0x0046);
  115.             SetMenuHelp(hwnd, INTRODUCTION_HELP, 0x0047);
  116.             SetMenuHelp(hwnd, MODEM_HELP, 0x0047);
  117.             SetMenuHelp(hwnd, DATA_BASE_HELP, 0x0047);
  118.             SetMenuHelp(hwnd, PORTABLE_HELP, 0x0047);
  119.             SetMenuHelp(hwnd, ORDER_HELP, 0x0047);
  120.             SetMenuHelp(hwnd, ABOUT, 0x0048);
  121.         }
  122.         return 0;
  123.     case WM_DESTROY:
  124.         DeleteObject((HFONT) GetWindowLong(hwnd, 0));
  125.         PostQuitMessage(0);
  126.         return 0;
  127.     case WM_COMMAND:
  128.         {
  129.             switch (wParam) {
  130.             case EXIT:
  131.                 DestroyWindow(hwnd);
  132.                 PostQuitMessage(0);
  133.                 return 0;
  134.             case DIALOG_STRING:
  135.                 {
  136.                     DLGPROC         testDialogProc;
  137.                     testDialogProc = (DLGPROC) MakeProcInstance((FARPROC) TestDialogProc, hInst);
  138.                     int             Test = DialogBox(hInst, "DialogTest", hwnd, testDialogProc);
  139.                     FreeProcInstance(testDialogProc);
  140.                     return 0;
  141.                 }
  142.             case MODEM_HELP:
  143.                 chdir(".\\help");
  144.                 WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0007);
  145.                 chdir("..");
  146.                 break;
  147.             case ORDER_HELP:
  148.                 WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0013);
  149.                 break;
  150.             case DATA_BASE_HELP:
  151.                 WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0003);
  152.                 break;
  153.             case PORTABLE_HELP:
  154.                 WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0005);
  155.                 break;
  156.             case INTRODUCTION_HELP:
  157.                 WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0001);
  158.                 break;
  159.             case INTRODUCTION_TRAINING:
  160.                 {
  161.                     if (Pl)
  162.                         Pl("training\\Intro.tra",FALSE,FALSE);
  163.                     break;
  164.                 }
  165.             case MODEM_TRAINING:
  166.                 {
  167.                     if (Pl)
  168.                         Pl("training\\Modem.tra",FALSE,FALSE);
  169.                     break;
  170.                 }
  171.                 break;
  172.             case DATA_BASE_TRAINING:
  173.                 {
  174.                     if (Pl)
  175.                         Pl("training\\DB.tra",FALSE,FALSE);
  176.                     break;
  177.                 }
  178.                 break;
  179.             case PORTABLE_TRAINING:
  180.                 {
  181.                     if (Pl)
  182.                         Pl("training\\Portable.tra",FALSE,FALSE);
  183.                     break;
  184.                 }
  185.                 break;
  186.             case ABOUT:
  187.                 {                                                     
  188.                     MessageBox(NULL, "Telephone Control \012 Copyright Maurizio Maccani 1995", "About", MB_OK);
  189.                     return 0;
  190.                 }
  191.             }
  192.         }
  193.     }
  194.     return DefWindowProc(hwnd, message, wParam, lParam);
  195. }
  196.  
  197.  
  198. BOOL FAR PASCAL __export TestDialogProc(HWND hDlg, UINT uMsg,
  199.                                                WPARAM wParam, LPARAM lParam)
  200. {
  201.     switch (uMsg) {
  202.  case WM_INITDIALOG:
  203.         typedef void    (FAR PASCAL * INTCODE) (HWND, int);
  204.         INTCODE         SetDefaultIntCode;
  205.         SetDefaultIntCode = (INTCODE) GetProcAddress(telLib, "SetDefaultIntCode");
  206.         if (SetDefaultIntCode)
  207.             SetDefaultIntCode(GetDlgItem(hDlg, IDC_EDIT1), 55);
  208.         SetFocus(GetDlgItem(hDlg, IDC_EDIT1));
  209.         SetWindowHelp(GetDlgItem(hDlg, IDC_EDIT1), 0x0049);
  210.         SetWindowHelp(GetDlgItem(hDlg, IDC_EDIT2), 0x0050);
  211.         SetWindowHelp(hDlg, 0x0051);
  212.         return 0;
  213.     case WM_CLOSE:
  214.         EndDialog(hDlg, 0);
  215.         return TRUE;
  216.     case WM_COMMAND:
  217.         switch (wParam) {
  218.         case IDOK:
  219.             EndDialog(hDlg, 0);
  220.             return TRUE;
  221.         default:
  222.             break;
  223.         }
  224.         break;
  225.     }
  226.     return (FALSE);
  227.  
  228. }                               // end of TestDialogProc()
  229.  
  230.  
  231. BOOL FAR PASCAL __export SharewareDialogProc(HWND hDlg, UINT uMsg,
  232.                                                WPARAM wParam, LPARAM lParam)
  233. {
  234.     switch (uMsg) {
  235.  case WM_CLOSE:
  236.         EndDialog(hDlg, 0);
  237.         return TRUE;
  238.     case WM_COMMAND:
  239.         switch (wParam) {
  240.         case IDOK:
  241.             EndDialog(hDlg, 0);
  242.             return TRUE;
  243.         }
  244.         break;
  245.     }
  246.     return (FALSE);
  247.  
  248. }                               // end of TestDialogProc()
  249.  
  250.